package com.th.apicenter.ry.service;


import com.th.apicenter.ry.ThRyData;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ry")
@Slf4j
public class ThRyDataController {


    @Autowired
    ThRyDataService thRyDataService;

    /**
     * 接收广告宏参数（与图片表格完全对应）
     * @param os 操作系统（0=Android, 1=iOS）
     * @param ip 用户IP地址（投放系统观测值）
     * @param oaid 匿名设备标识
     * @param requestId 广告请求ID
     * @param advertiserId 广告主ID（荣耀侧归因用）
     * @param trackId 转化事件追踪ID
     * @param creativeId 创意标识（crld）
     * @param time 事件时间（毫秒时间戳）
     * @param ua 用户UserAgent
     * @param groupId 广告分组ID
     * @param campaignId 广告计划ID
     */
    @GetMapping("/monitor")
    public String ryMonitor(
            @RequestParam(name = "account_id" ,defaultValue = "",required = false)  String accountId,
            @RequestParam(name = "os",defaultValue = "")  String os,
            @RequestParam(name = "ip",defaultValue = "",required = false) String ip,
            @RequestParam(name = "oaid",required = false) String oaid,
            @RequestParam(name = "request_id",defaultValue = "",required = false)  String requestId,
            @RequestParam(name = "advertiser_id",defaultValue = "",required = false) String advertiserId,
            @RequestParam(name = "track_id",defaultValue = "",required = false) String trackId,
            @RequestParam(name = "creative_id", required = false) String creativeId,
            @RequestParam(name = "time",defaultValue = "0",required = false)  String time,
            @RequestParam(name = "ua", required = false) String ua,
            @RequestParam(name = "group_id", required = false) String groupId,
            @RequestParam(name = "campaign_id", required = false) String campaignId) {

        ThRyData thRyData=new ThRyData(null,accountId,os,ip,oaid,requestId,advertiserId,trackId,creativeId,Long.parseLong(time),ua,groupId,campaignId,null,null,null);


        String result = thRyDataService.ryMonitor(thRyData);



        return "SUCCESS";
    }


}
